package cn.fengkuok.core.workflow.jbpm;

import javax.annotation.Resource;

import org.jbpm.api.ProcessEngine;

public abstract class JbpmSupport {
	private JbpmTemplate jbpmTemplate;
	//private ProcessEngine processEngine;

	//--------------------------------
	public JbpmSupport(){
	}
	
	public final ProcessEngine getProcessEngine() {
		return (this.jbpmTemplate != null ? this.jbpmTemplate.getProcessEngine() : null);
	}

	//注入
	@Resource(name = "processEngine")
	public final void setProcessEngine(ProcessEngine processEngine) {
		if(this.jbpmTemplate == null || processEngine != this.jbpmTemplate.getProcessEngine()) {
			this.jbpmTemplate = createJbpmTemplate(processEngine);
		}
		
	}

	/**
	 * 
	 * @param processEngine
	 * @return
	 */
	protected JbpmTemplate createJbpmTemplate(ProcessEngine processEngine) {
		return new JbpmTemplate(processEngine);
	}

	public final JbpmTemplate getJbpmTemplate() {
		return jbpmTemplate;
	}

	public final void setJbpmTemplate(JbpmTemplate jbpmTemplate) {
		this.jbpmTemplate = jbpmTemplate;
	}
	
	//---------------------
	/**
	 * 回退
	 * 取回
	 * 会签
	 * 委派
	 * 自由活动
	 * .......
	 */
}
